local juanwang = fk.CreateSkill{
    name = "ym2__juanwang",
}
Fk:loadTranslationTable{
    ["ym2__juanwang"] = "捐往",
    [":ym2__juanwang"] = "出牌阶段限一次，你可以拼点，然后输家使用此次拼点牌中的伤害牌或失去1点体力，此流程重复至你赢。",
    ["#ym2__juanwang"] = "捐往：与一名角色拼点，输家使用拼点牌中的伤害牌或失去1点体力",
    ["#ym2__juanwang-use"] = "捐往：使用拼点牌中的伤害牌，或失去1点体力",

    ["$ym2__juanwang1"] = "策略以入算，果烈以立威！",
    ["$ym2__juanwang2"] = "诈与和亲，不攻可得！",
}
juanwang:addEffect("active",{
    anim_type = "offensive",
    prompt = "#ym2__juanwang",
    max_phase_use_time = 1,
    card_num = 0,
    target_num = 1,
    can_use = function(self, player)
        return not player:isKongcheng() and player:usedSkillTimes(juanwang.name, Player.HistoryPhase) == 0
    end,
    card_filter = Util.FalseFunc,
    target_filter = function(self, player, to_select, selected, selected_cards)
        return #selected == 0 and to_select ~= player and player:canPindian(to_select)
    end,
    on_use = function(self, room, effect)
        local player = effect.from
        local to = effect.tos[1]
        while player:canPindian(to) do
            local pindian = player:pindian({to}, juanwang.name)
            if player.dead then return end
            local loser = nil
            if pindian.results[to].winner == player then
                loser = to
            elseif pindian.results[to].winner == to then
                loser = player
            end
            if loser and not loser.dead then
                local ids = {}
                table.insert(ids, pindian.fromCard:getEffectiveId())
                table.insert(ids, pindian.results[to].toCard:getEffectiveId())
                local patternIds = table.filter(ids, function(id)
                    local card = Fk:getCardById(id)
                    return card.is_damage_card and loser:canUse(card, { bypass_times = true })
                end)
                local use = room:askToUseRealCard(loser, {
                    pattern = patternIds,
                    skill_name = juanwang.name,
                    prompt = "#ym2__juanwang-use",
                    extra_data = {
                        bypass_times = true,
                        extraUse = true,
                        expand_pile = ids,
                    },
                })
                if not use then
                    room:loseHp(loser,1,juanwang.name)
                end
            end
            if pindian.results[to].winner == player then break end
        end
    end,
})
return juanwang